<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <title>快乐打工网后台管理系统</title>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       <link href="${pageContext.request.contextPath}/assets/css/bs3/dpl.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath}/assets/css/bui-min.css" rel="stylesheet" type="text/css" />
    <link href="${pageContext.request.contextPath}/assets/css/page-min.css" rel="stylesheet" type="text/css" />   <!-- 下面的样式，仅是为了显示代码，而不应该在项目中使用-->
   <link href="${pageContext.request.contextPath}/assets/css/prettify.css" rel="stylesheet" type="text/css" />
   <style type="text/css">
    code {
      padding: 0px 4px;
      background-color: #f7f7f9;
      border: 0px solid #e1e1e8;
    }
   </style>
 </head>
 <body background="${pageContext.request.contextPath}/images/bg5.jpg">
  
  <div class="container">
  <form  class="form-horizontal" action="${pageContext.request.contextPath}/companyWeb/companyListByConditionsWeb.do" method="post">
    <div class="row">
    <div class="span25 offset3 control-row-auto">
                公司名称：<input type="text" name="cname" id="search"></input>&nbsp;
                公司地址： <select  name="caddress" class="input-normal"> 
                <option value="">--请选择--</option>
                <option value="北京市">北京市</option>
                <option value="上海">上海市</option>
                <option value="洛阳市">洛阳市</option>
                <option value="广东省">广东省</option>
              </select>&nbsp;
                         公司规模：<input type="text" name="ccount" id="search"></input>&nbsp;
                         优惠政策：<input type="text" name="clabourcost" id="search"></input>
       <button type="submit" id="J_Btn">查询</button>
     </div>
    </div></form>
    <div class="row">
       <div class="span21 offset3 control-row-auto">
          <div id="grid"></div>
       </div>
    </div>
    <div id="content" class="hide">
      <form id="J_Form" class="form-horizontal" action="${pageContext.request.contextPath}/companyWeb/updateCompanyInfoWeb.do"  method="post">
        <div class="row">
          <div class="control-group span9">
            <label class="control-label"><s>*</s>公司名称：</label>
            <div class="controls">
              <input name="cname" type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
           <div class="control-group span9">
            <label class="control-label"><s>*</s>公司规模：</label>
            <div class="controls">
              <input name="ccount" type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label"><s>*</s>公司地址：</label>
            <div class="controls">
              <input name="caddress" type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="control-group span9 ">
            <label class="control-label"><s>*</s>优惠政策：</label>
            <div class="controls">
              <input  type="text"  name="clabourcost" data-rules="{required:true}"/>
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label"><s>*</s>公司编号：</label>
            <div class="controls">
              <input name="cno" type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label"><s>*</s>公司标签：</label>
            <div class="controls">
              <input name="remark"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="control-group span9">
            <label class="control-label">最低薪资：</label>
            <div class="controls">
              <input name="csalaryl"  type="text" data-rules="{required:true}" class="control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label">最高薪资：</label>
            <div class="controls">
              <input name="csalaryh"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label">发薪日期：</label>
            <div class="controls">
              <input name="cpaydate"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
           <div class="control-group span9">
            <label class="control-label"><s>*</s>薪资结构：</label>
            <div class="controls" >
             <input name="cpaydetail"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label">薪资发放：</label>
            <div class="controls">
              <input name="cpayexplain"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
          <div class="control-group span9">
            <label class="control-label">伙食：</label>
            <div class="controls">
              <input name="cmeals"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
         </div> 
         <div class="row">
          <div class="control-group span9">
            <label class="control-label"><s>*</s>住宿：</label>
            <div class="controls">
              <input name="chousing"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
           <div class="control-group span9">
            <label class="control-label">公司班车：</label>
            <div class="controls">
              <input name="ctraffic"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="control-group span9">
            <label class="control-label">工作培训：</label>
            <div class="controls">
              <input name="ctrain"  type="text" data-rules="{required:true}" class="input-normal control-text">
            </div>
          </div>
           <div class="control-group span9">
            <label class="control-label">工时说明：</label>
            <div class="controls">
              <input name="cworktime"  type="text"  class="input-normal control-text">
            </div>
          </div>
        <div class="control-group span9">
            <label class="control-label">工作内容：</label>
            <div class="controls">
              <input name="cworkenvironment"  type="text"  class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <input name="cid"  readonly="readonly" type="hidden" data-rules="{required:true}" class="input-normal control-text">
        </div>
        <div class="row">
          <div class="control-group span9">
              <label class="control-label"><s>*</s>签订合同：</label>
              <div class="controls">
                <input name="ccontract" data-rules="{required:true}" type="text">
              </div>
           </div>
           <div class="control-group span9">
            <label class="control-label">五险福利：</label>
            <div class="controls">
              <input name="cinsurance"  type="text"  class="input-normal control-text">
            </div>
          </div>
           <div class="control-group span9">
            <label class="control-label"><s>*</s>公司图标：</label>
            <div class="controls">
              <input name="cphoto"  type="text"  class="input-normal control-text">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="control-group span9">
            <label class="control-label">公司介绍：</label>
            <div class="controls">
              <input name="cinformation" style="width:200px;" type="text"  class="input-normal control-text">
            </div>
          </div>
          
        </div>
        <div class="row">
        <div class="form-actions offset3">
          <button type="submit" class="button button-primary">保存</button>
        </div>
      </div>
      </form>
    </div>
  </div>
  <script type="text/javascript" src="${pageContext.request.contextPath}/assets/js/jquery-1.8.1.min.js"></script>
  <script type="text/javascript" src="${pageContext.request.contextPath}/assets/js/bui.js"></script>

  <script type="text/javascript" src="${pageContext.request.contextPath}/assets/js/config-min.js"></script>
  <script type="text/javascript">
    BUI.use('common/page');
  </script>

  <!-- 仅仅为了显示代码使用，不要在项目中引入使用-->
  <script type="text/javascript" src="${pageContext.request.contextPath}/assets/js/prettify.js"></script>
  <script type="text/javascript">
    $(function () {
      prettyPrint();
    });
  </script> 
<script type="text/javascript">
  BUI.use(['bui/grid','bui/data','bui/form'],function (Grid,Data,Form) {

    var columns = [{title : 'cid',dataIndex :'cid',width:10,visible:false},
                   {title : '公司名称',dataIndex :'cname',width:80},
                   {title : '公司地点',dataIndex :'caddress',width:70},
                   {title : '公司规模',dataIndex :'ccount',width:30},
                   {title : '保底薪资',dataIndex :'csalaryl',width:30},
                   {title : '最高薪资',dataIndex :'csalaryh',width:30},
                   {title : '优惠政策',dataIndex :'clabourcost',width:60},
                   {title : '公司标签',dataIndex :'remark',width:60},
                   {title : '发薪日',dataIndex :'cpaydate',width:60,visible:false},
                   {title : '薪资结构',dataIndex :'cpaydetail',width:60,visible:false},
                   {title : '伙食',dataIndex :'cmeals',width:60,visible:false},
                   {title : '住宿',dataIndex :'chousing',width:60,visible:false},
                   {title : '公司班车',dataIndex :'ctrafffic',width:60,visible:false},
                   {title : '上班工时',dataIndex :'cworktime',width:60,visible:false},
                   {title : '工作环境',dataIndex :'cworkenvironment',width:60,visible:false},
                   {title : '入职培训',dataIndex :'ctrain',width:60,visible:false},
                   {title : '公司编号',dataIndex :'cno',width:60,visible:false},
                   {title : '公司合同',dataIndex :'ccontract',width:60,visible:false},
                   {title : '薪资说明',dataIndex :'cpayexplain',width:60,visible:false},
                   {title : '五险福利',dataIndex :'cinsurance',width:60,visible:false},
                   {title : '公司图标',dataIndex :'cphoto',width:60,visible:false},
                   {title : '公司介绍',dataIndex :'cinformation',width:60,visible:false},
		           {title : '操作',renderer : function(){
		               return '<span class="grid-command btn-edit">编辑</span>';
		              },
                   width:40},
                   {title : '操作',renderer : function(){
		               return '<span class="grid-command btn-del" title="删除">删除</span>';},
		           width:50}
          ],
      //默认的数据
      data = ${companyList},
      store = new Data.Store({
        data:data,
        pageSize:15
      }), 
      editing = new Grid.Plugins.DialogEditing({
        contentId : 'content',
        triggerCls : 'btn-edit',
        eidtor : {
          focusable : false,
          triggerSelected:true
        }
      }),
      cascade = new Grid.Plugins.Cascade({
    	  renderer:function(record){
    		  return '<div style="padding:12px 14px;background:lightgray;"><h3><font color="blue"><a href="${pageContext.request.contextPath}/companyWeb/companyInfoByCidWeb.do?cid='+record.cid+'">查看公司更多详情信息</a></font></h3></div>'; 
    	  }
      }),
      grid = new Grid.Grid({
        render : '#grid',
        columns : columns,
        width : 1000,
        loadMask:true,//加载数据时显示屏蔽层
        forceFit : true,//标签元素宽度自适应
        store : store,
        plugins : [Grid.Plugins.CheckSelection,editing,cascade],
        tbar:{
           items : [{
               btnCls : 'button button-small',
               text : '<i class="icon-remove"></i> 批量删除',
               listeners : {
                 'click' : delFunction
               }
             }] 
        },
        bbar:{
        	pagingBar:true
        }

      });
    grid.render();

    function addFunction(){
      var newData = {school :'请输入'};
      editing.add(newData); //添加记录后，直接编辑 
    }
    function delFunction(){
        var selections = grid.getSelection();
        //store.remove(selections);
        delItems(selections);
      }
    function delItems(items){
          var ids = [];
          BUI.each(items,function(item){
            ids.push(item.cid);
          });
          var ids1= BUI.JSON.stringify(ids);
          if(ids.length){
            BUI.Message.Confirm('确认要删除选中的记录么？',function(){
              $.ajax({
                url : '${pageContext.request.contextPath}/companyWeb/deleteCompanyWeb.do',
                dataType : 'json',
                data : {ids:ids1},
                success : function(data){
                  if(data=="1"){ //删除成功
                  	BUI.Message.Alert('删除成功！');
                  	window.location.href='${pageContext.request.contextPath}/companyWeb/companyListWeb.do';
                  }else{ //删除失败
                    BUI.Message.Alert('删除失败！'+data);
                  }
                }
            });
            },'question');
          }
        }
      //监听事件，删除一条记录
      grid.on('cellclick',function(ev){
        var sender = $(ev.domTarget); //点击的Dom
        if(sender.hasClass('btn-del')){
          var record = ev.record;
          delItems([record]);
        }
      });
    });
</script>

<body>
</html> 